package com.android.jay.wzp_voice.view.loading;

import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;


import com.android.jay.lib_commin_ui.base.BaseActivity;
import com.android.jay.lib_pullalive.app.AliveJobService;
import com.android.jay.wzp_voice.R;
import com.android.jay.wzp_voice.view.home.HomeActivity;

import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;

/**
 * Created by wzp on 2020/2/4 0004.
 * <p>
 * 描述  ：启动页面
 */
public class LoadingActivity extends BaseActivity {

    private Handler handler = new Handler(Looper.getMainLooper()) {
        @Override
        public void handleMessage(Message msg) {
            startActivity(new Intent(LoadingActivity.this, HomeActivity.class));
            finish();
        }

    };


    @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.loading_activity_layout);
        pullAlive();
        //获取权限
        handler.sendEmptyMessageDelayed(0, 3000);
    }

    @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
    private void pullAlive() {
        AliveJobService.start(this);
    }


    @Override
    protected void onDestroy() {
        super.onDestroy();
        handler.removeCallbacksAndMessages(null);
    }
}
